<%@ page import="support.*, java.util.*, java.sql.*, javax.sql.*" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<jsp:include page="header.jsp" />

	<div id="content" class="expand">
		<h2>Graduate Application</h2>
		
		<p>Applications for selected criteria:</p>

		<%
		String username = request.getUserPrincipal().getName();
		
		Vector applications = (Vector)session.getAttribute("applications");
		for (int i = 0; i < applications.size(); i++) {
			out.print("<p>");
			HashMap app = (HashMap)applications.get(i);
			out.print(app.get("firstName") + " " + app.get("lastName") + " - " + " Average Grade: " + app.get("aveGrade") + " - "
					+ app.get("status") + " | ");
			if (app.get("status").equals("pending")) {
				out.print(" <a href='setStatus.do?status=admitted&app=" + app.get("id") + 
						"'>admit</a> | <a href='setStatus.do?status=rejected&app=" + app.get("id") + 
						"'>reject</a>"); 
			}
			else if (app.get("status").equals("admitted")) {
				out.print(" <a href='setStatus.do?status=pending&app=" + app.get("id") + 
						"'>cancel</a> | <a href='setStatus.do?status=rejected&app=" + app.get("id") + 
						"'>reject</a>");
			}
			else if (app.get("status").equals("rejected")) {
				out.print(" <a href='setStatus.do?status=pending&app=" + app.get("id") + 
						"'>cancel</a> | <a href='setStatus.do?status=admitted&app=" + app.get("id") + 
						"'>admit</a>");
			}
			%>
			<input type=button value='Show Application' onclick='toggle("<%= i %>"); showAppInfo("<%= app.get("id") %>");' id='<%= i %>'">
			<%
			out.print("</p>");
		}
		%>
	
	<div id='repl' style="border-top:1px solid black; padding-top:20px;">
	<%-- -------- Populate application info inside here -------- --%>
	</div>
	
	</div>

</body>
</html>

